FILE(GLOB BAR_PROTOS "*.proto")


MESSAGE(STATUS "PROTO_META_BASE_DIR " ${PROTO_META_BASE_DIR})

FOREACH(FIL ${BAR_PROTOS})
  GET_FILENAME_COMPONENT(ABS_FIL ${FIL} ABSOLUTE)
  GET_FILENAME_COMPONENT(FIL_WE ${FIL} NAME_WE)

  LIST(APPEND BAR_SRCS "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
  LIST(APPEND BAR_HDRS "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")

  EXECUTE_PROCESS(
      COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${PROTO_META_BASE_DIR} ${FIL}
      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  )
ENDFOREACH()

MESSAGE(STATUS "BAR_PROTOS " ${BAR_PROTOS})
MESSAGE(STATUS "BAR_SRCS " ${BAR_SRCS})
MESSAGE(STATUS "BAR_HDRS " ${BAR_HDRS})

ADD_LIBRARY(bar ${BAR_SRCS})



TARGET_LINK_LIBRARIES(bar foo)

